﻿using System;
using System.Collections.Generic;

namespace _025.列表的常用操作
{
	internal class Program
	{
		static void Main(string[] args)
		{
			List<int> list = new List<int>() { 56, 23, 894,32, 5623, 4573 };

			Console.WriteLine("list的容量：" + list.Capacity);
			Console.WriteLine("list的个数：" + list.Count);

			// 列表的插入
			list.Insert(3, 800);
			ShowList(list);

			// 删除
			list.Remove(5623);
			// 通过索引移除
			//list.RemoveAt(5623);
			ShowList(list);

			// 查询 不存在-1
			//Console.WriteLine(list.IndexOf(32));
			Console.WriteLine(list.LastIndexOf(32));
		}

		static void ShowList(List<int> list)
		{
			foreach (int i in list)
				Console.Write(i + " ");
			Console.WriteLine();
		}
	}
}
